{include file="layout/top"/}
<form action="" method="post" class="form_single">
    <div class="box">
      <div class="box-body">
        <div class="row">
          <div class="col-md-4">
          <div class="form-group">
            <label>调职公司</label>
            <span class="">（员工调职公司）</span>
              <select name="company_id" class="form-control" id="company_list">
                <option value="0" >请选择公司</option>
                  {volist name='company_list' id='vo'}
                      <option value="{$vo['id']}" >{$vo['name']}</option>
                  {/volist}
              </select>
          </div>
        </div>
        <div class="col-md-4">
          <div class="form-group">
            <label>调职部门</label>
            <span class="">（员工调职部门）</span>
              <select name="branch_id" class="form-control" id="branch_list">
                <option value="0" >请选择部门</option>
                  <!-- {volist name='branch_list' id='vo'}
                      <option value="{$vo['id']}" >{$vo['branch_name']}</option>
                  {/volist} -->
              </select>
          </div>
        </div>
        <div class="col-md-4">
          <div class="form-group">
            <label>所属组</label>
            <span class="">（员工所属部门组非必选）</span>
              <select name="group_id" class="form-control" id="group_list">
                  <option value="6" >请选择组</option>
                  <!-- {volist name='group_list' id='vo'}
                      <option value="{$vo['id']}" >{$vo['group_name']}</option>
                  {/volist} -->
              </select>
          </div>
        </div>
          <div class="col-md-6">
            <div class="form-group">
              <label>岗位</label>
              <span>（调职的新岗位名）</span>
              <input class="form-control" name="p_name" placeholder="请输入岗位" type="text">
            </div>
          </div>

           <div class="col-md-4">
            <div class="form-group">
              <label>调职时间</label>
              <span class="">（调职的时间）</span>
                <input type="text" name="move_time" readonly="readonly" style="cursor:pointer"  class="form-control test-item" placeholder="请选择时间" >
            </div>
          </div>

          <div class="col-md-6">
            <div class="form-group">
              <label>备注</label>
              <span>（调职备注）</span>
              <textarea class="form-control" name="m_reson" rows="3" placeholder="请输入调职备注"></textarea>
            </div>
          </div>

        </div>
      </div>
      <div class="box-footer">
         <input type="hidden" class="form-control staff_id" name="staff_id" value="{$staff_id}"/>
        <button  type="button" style="color:#fff;background:#3c8dbc;" class="btn ladda-button ajax-post-tj" data-style="slide-up" target-form="form_single" url="{:url()}">
      <span class="ladda-label"><i class="fa fa-send"></i> 确 定</span>
    </button>

<!-- <a class="btn yh_close" style="color:#fff;background:#3c8dbc;" href="javascript:;"><i class="fa fa-history"></i> 返 回</a> -->
      </div>
    </div>
    <script src="__STATIC__/module/admin/laydate/laydate.js"></script>
    <script src="__STATIC__/module/admin/laydate/layer.js"></script>
    <script type="text/javascript">
  $('#company_list').change(function(){
    var options=$(this).children("option:selected");
     // options.attr('selected','selected'); 
    var company_id=options.val();
    $('#branch_list option').remove();
    $('#group_list option').remove();
     $("#group_list").append("<option value=''>请选择组</option>");
     $("#branch_list").append("<option value=''>请选择部门</option>");
    $.post('/admin/branch/branchlist',{company_id:company_id},function(data){
      $(data.data).each(function(index,item){ 
          var option="<option value="+item.id+">"+item.branch_name+"</option>"
          $("#branch_list").append(option);  
            // console.log(item); 
        }); 
    });  
  })

  $('#branch_list').change(function(){
    var options=$(this).children("option:selected");
     options.attr('selected','selected'); 
    var branch_id=options.val();
    $('#group_list option').remove();
     $("#group_list").append("<option value=''>请选择组</option>");
    // alert(branch_id);
    $.post('/admin/group/grouplist',{branch_id:branch_id},function(data){
      $(data.data).each(function(index,item){ 
          var option="<option value="+item.id+">"+item.group_name+"</option>"
          $("#group_list").append(option);  
            console.log(item); 
        }); 
    });  
  })
      // 时间插件      
    $('.ajax-post-tj').click(function(){
      var target=$(this).attr('url');
      var staff_id=$('.staff_id').val();
      var query = $('.form-control').serialize();
      // alert(target);
      $.post(target,query).success(function(data){ 
        layer.msg(data.msg);
        setTimeout(function(){
           layer.close(layer.index);
          window.parent.location.reload();
        },2000)
      });
    })
    lay('.test-item').each(function(){
      laydate.render({
        elem: this
        ,trigger: 'click'
      });
   });
    </script>
</form>
